package com.he.ymw.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/").setViewName("Index");
//        registry.addViewController("index").setViewName("Index");
//        registry.addViewController("index.html").setViewName("Index");
    }

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(
                new MyHandlerInterceptor()).addPathPatterns("/**").
                excludePathPatterns("/index","/index.html",
                        "/register","/toLogin","/toRegist","/findUserName/**",
                        "/findMobile/**","/sendCaptcha/**","/login",
                        "/css/**","/images/**","/js/**","/layui/**");
    }
}
